package cn.jsc.user.config;

import cn.jsc.user.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 配置自定义拦截器
 */
@Configuration
public class MyWebConfig implements WebMvcConfigurer{
    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                //拦截地址，拦截所有
                .addPathPatterns("/**")
                //放行地址 登录，注册，店铺入驻，上传图像，验证码，swagger测试
                .excludePathPatterns("/login/**")//登录
                .excludePathPatterns("/user/register/**")//用户注册
                .excludePathPatterns("/shop/settlement")//店铺入驻=管理员注册
                .excludePathPatterns("/fastDfs")//文件上传
                .excludePathPatterns("/verifycode/**")//验证码
                .excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**")  //放行swagger测试
                .excludePathPatterns("/notify"); //放行支付包支付的异步通知
    }

}
